package me.fanwu;

import static spark.Spark.get;
import static spark.Spark.post;

/**
 * Wupher 编写于 16/7/29.
 */
public class Deployer {
    public static void main(String[] args) {
        get("/", (request, response) -> "Hello, World!");
        post("/shell", (request, response) -> {
            String cmdStr = request.attribute("cmd");
            if (null == cmdStr || 0 == cmdStr.length()) {
                cmdStr = "mvn compile package";
            }
            ExecuteShellComand cmd = new ExecuteShellComand();
            String result =
                    cmd.executeCommand(cmdStr);
            response.status(200);
            return result;
        });
    }
}
